﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenChart.Entities;
using System.Drawing;

using OpenChart.PublicUnits;

namespace OpenChart.DrawChart
{
    class DrawingDotChart:DrawingLineChart
    {
        protected override void DrawData()
        {
            base.DrawData();
        }

        /// <summary>
        /// 根据Series绘制图形
        /// </summary>
        /// <param name="item">Series</param>
        protected override void DrawSeries(Series item)
        {
            PointF point;
            for (int i = 0; i < this.ChartArea.Data.Rows.Count; i++)
            {
                double xValue = ChartHelper.GetDoubleValue(this.ChartArea.Data.Rows[i][this.ChartArea.XValueMember], this.ChartArea.AxisX.IntervalType);
                if (xValue < _minXValue || xValue > _maxXValue)
                {
                    continue;
                }
                double yValue = ChartHelper.GetDoubleValue(this.ChartArea.Data.Rows[i][item.YValueMember], this.ChartArea.AxisY1.IntervalType);
                if (yValue < _minYValue || yValue > _maxYValue)
                {
                    continue;
                }
                point = this.GetPoint(xValue, yValue);
                this.DrawPoint(point, item.Color, item.Width);
            }
        }

        //绘制一个坐标点
        private void DrawPoint(PointF point, Color color, int width)
        {
            Brush brush = new SolidBrush(color);
            Pen pen = new Pen(brush, width);
            this.Graphics.DrawEllipse(pen, point.X - (float)width / 2, point.Y - (float)width / 2, width, width);
        }
    }
}
